package com.quan;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

@EnableDiscoveryClient
@EnableFeignClients
@EnableCaching
@SpringBootApplication
public class SystemApplication implements CommandLineRunner, DisposableBean {

	private static final Logger logger = LoggerFactory.getLogger(SystemApplication.class);

	public static void main(String[] args) {
		SpringApplication.run(SystemApplication.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		logger.info("**********************************************");
		logger.info("SYSTEM-系统管理服务启动.....");
		logger.info("**********************************************");
	}

	@Override
	public void destroy() throws Exception {
		logger.info("**********************************************");
		logger.info("SYSTEM-系统管理服务关闭.....");
		logger.info("**********************************************");
	}
	
	/*@Bean
	public HttpMessageConverters fastJsonHttpMessageConverters() {
		//1.需要定义一个convert转换消息的对象;
	    FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
	    //2:添加fastJson的配置信息;
	    FastJsonConfig fastJsonConfig = new FastJsonConfig();
	    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
	    
	    //3.将所有Long类型转换成字符串类型（不转换的话，传到前端Long类型数据会丢失精度，ID字段类型为Long）
        fastJsonConfig.setSerializerFeatures(SerializerFeature.BrowserCompatible);
	    
	    //4.处理中文乱码问题
	    List<MediaType> fastMediaTypes = new ArrayList<>();
	    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
	    
	    //5.在convert中添加配置信息.
	    fastJsonHttpMessageConverter.setSupportedMediaTypes(fastMediaTypes);
	    fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig);
	    HttpMessageConverter<?> converter = fastJsonHttpMessageConverter;
	    return new HttpMessageConverters(converter);
	}*/
	

}
